#include "sensor.h"

float vbus = 0.0f;
float current_u = 0.0f;
float current_v = 0.0f;
float current_w = 0.0f;
float current_u_offset = 0.0f;
float current_v_offset = 0.0f;
float current_w_offset = 0.0f;

void calVbus(uint16_t adcValue)
{
  vbus = ((float)adcValue / 4095.0f) * 3.3f * 8.0f;
}

void calCurrentUVW(uint16_t adcValue_U, uint16_t adcValue_V)
{
  current_u = (((float)adcValue_U / 4095.0f) * 3.3f - 1.65f) / 0.5f;
  current_w = (((float)adcValue_V / 4095.0f) * 3.3f - 1.65f) / 0.5f;
  current_v = -current_u - current_w;
}
